package org.bao.action;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.bao.bean.OrderNumB;
import org.bao.service.impl.PhoneServiceImpl;
import org.bao.utils.MyUtils;

/**
 * Servlet implementation class OrderNum
 */

/**
* @ClassName: OrderNum
* @Description: 接受订单号和用户tel和商品id写入数据库
* @author bql
* @date 2018年10月1日
*
*/
@WebServlet("/OrderNum")
public class OrderNum extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#service(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//		 接受商品id
		String phoneid = request.getParameter("phoneid");
		System.out.println("phoneid:" + phoneid);
		//接受用户tel
		String usertel = (String) request.getSession().getAttribute("userTel");
		System.out.println("usertel:" + usertel);
		//接受订单号
		String ordernumber = request.getParameter("orderNum");
		System.out.println("ordernumber:" + ordernumber);
		
		//创建一个对象
		OrderNumB orderB = MyUtils.getInstance(OrderNumB.class);

		//将接受到的信息写入对象
		orderB.setOrdernumber(ordernumber);
		orderB.setPhoneid(phoneid);
		orderB.setUsertel(usertel);
		
		//写入数据库中
		int i = MyUtils.getInstance(PhoneServiceImpl.class).orderNumOrID(orderB);
		System.out.println("i:" + i);
		
		
	}

}
